var bfForm = new Ext.FormPanel({
		border : true,
		layout : 'form',
		width:300,
        baseCls : 'ex-panel',//设置透明FORM 嵌入页面
		items:[{
			border : false,
			html : '<div id="indexTop"><ul><li style="height:50px;"><img style="height:50px;" src="../images/ext3/logo.png" /></li><li id="clock"></li><li><font style="font-size:16px;font-weight:bold;">欢迎您！'+i1510.curUser+"["+i1510.curCompany+"]</font></li><ul></div>",
			anchor : '95%'
		}]
	});
var IndexPage = Ext.extend(Ext.Viewport, {
	top : {
			id:'top-panel',
	        region: 'north',
	        height: 60,
	        margins: '5 5 5 5',
	        items:[bfForm],
	        collapsible : false,
			split : true,
			autoScroll : false,
			frame:true,
	        align:'center',
//	        cls : 'loginbgimage',//设置页面背景的CSS
//	        baseCls : 'ex-panel',//设置透明FORM 嵌入页面
	        layout : 'column',
			border : true
	},
//	top : {
//            cls: 'app-header',
//            region: 'north',
//            height: 30,
//            html: '<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed;background-image: url(../js/ext3/resources/images/default/panel/top-bottom.png) !important;">'+
//				  '<tr><td width="254px" >&nbsp;&nbsp;&nbsp;&nbsp;'+i1510.webTitle+'</td>'+
//				  '<td width="544px" align="right" id="clock" >&nbsp;&nbsp;&nbsp;&nbsp;</td>'+
//				  '</tr>'+
//				'</table>',
//            margins: '5 5 5 5'
//    },
	west : {
			id:'west-panel',
			region : 'west',
			title : "导航",
			split : true,
			width : 180,
	        minSize: 150,
	        maxSize: 300,
	        margins: '0 3 5 5',
			iconCls : 'menu-navigation',
			autoScroll : false,
			layout : 'accordion',
			collapsible : true
	},
	center:{
			region : 'center',
			margins: '0 5 5 0',
			border: false,
			html : '<iframe id="main" src="'+i1510.contextPath+'/common/sysUser/sysUser_list.jsp" width="100%" height="100%" scrolling="auto" frameborder="0" ></iframe>'
	},
	south : {
			region : 'south',
			height : 30,
			tbar : [{
						text : '退出系统',
						iconCls : 'btn-logout',
						handler : function() {
							App.logoutSystem();
						}
					},
//					'-',{
//						tag:'div',
//						html:" 欢迎您！"+i1510.curUser
//					},
					{
						text : '回到首页',
						iconCls : 'menu-navigation',
						handler : function() {
							App.login();
						}
					},'->', {
						xtype : 'combo',
						mode : 'local',
						editable : false,
						value : '切换皮肤',
						width : 100,
						triggerAction : 'all',
						store : [['ext-all', '默认风格'], 
								['xtheme-gray', '银白风格'],
								['xtheme-purple', '紫色风格'], 
								['xtheme-olive', '绿色风格'],
								['xtheme-darkgray', '灰色风格']],
						listeners : {
							scope : this,
							select : function(d, b, c) {
								if (d.value != "") {
									var xthemem = i1510.contextPath+"/common/js/ext3/resources/css/"+ d.value + ".css";
									App.setCookie("i1510-xtheme",xthemem,7);
									Ext.util.CSS.swapStyleSheet("theme", xthemem);//更新样式
									var iframe = document.getElementById("main");
									iframe.src = iframe.src;//重新加载
									//iframe.src = i1510.contextPath+'/common/sysUser/sysUser_list.jsp';
								}
							}
						}
					}]
	},
	constructor : function() {
		//构造函数
		IndexPage.superclass.constructor.call(this, {
					layout : 'border',
					items : [this.top,this.west,this.center,this.south]
				});
		var clock = new Clock();
    	clock.display(document.getElementById("clock"));
		this.loadMenu();
	},
	loadMenu : function(){
		var toolBar = Ext.getCmp("top-toolbar");
		Ext.Ajax.request({
			url : i1510.contextPath+'/admin/sysUser/findMenu.do',
            scope: this,
			success : function(response, options) {
				if(response.getResponseHeader("SessionTimeout")){
					Ext.MessageBox.show({
					    title: '操作提示 ',
					    msg: '超时,3秒后返回登陆界面！ ',
					    progress:true,
					    wait:true,
					    progressText:"进度条",
//					    prompt:true,输入文本框
//					    multiline:true,多行文本框
//					    buttons: Ext.MessageBox.OK,
					    icon: Ext.MessageBox.WARNING
					});
					window.setTimeout(function() {
						location.href = i1510.contextPath+'/common/login/login.jsp';
					}, 3000);
					
				}
				var menudata = eval(response.responseText);
				if(menudata){
					var westPanel = Ext.getCmp("west-panel");
					for (var i = 0; i < menudata.length; i++) {
						var panel = new Ext.tree.TreePanel({
							id : menudata[i].id,
							title : menudata[i].text,
							iconCls : menudata[i].iconCls,
							layout : "fit",
							animate : true,
							border : false,
							autoScroll : true,
							loader : new Ext.tree.TreeLoader(),
							root : new Ext.tree.AsyncTreeNode({
										expanded: true,
										children: menudata[i].children
									}),
							listeners : {
								scope : this,
								click:  this.clickMenu
							},
							rootVisible : false
						});
						westPanel.add(panel);
						westPanel.doLayout();
					}
				}
			},
			failure: function(response, options){
				Ext.Msg.alert("错误提示","菜单初始化失败!");
			}
		});
	},
	clickMenu : function(n){
		var iframe = document.getElementById("main");
		iframe.src = n.attributes.url;
	}
});